'use strict';

function addEvent(elem, type, handle) {
    if (elem.addEventListener) {
        elem.addEventListener(type, handle, false);
    }else if(elem.attachEvent) {
        elem.attachEvent('on' + type, handle);
    }else{
        elem['on' + type] = handle;
    }
}

(function () {
    // menu
    var hidden_menu_btn = document.getElementsByClassName('hidden-menu-btn')[0];
    if (hidden_menu_btn) {
        addEvent(hidden_menu_btn, 'click', function() {
            var backmanage_layout = document.getElementsByClassName('backmanage-layout')[0];

            var classList = [].slice.call(backmanage_layout.classList, 0);
            if (classList.indexOf('side-shrink') > -1) {
                backmanage_layout.classList.remove('side-shrink');
                hidden_menu_btn.classList.remove('active');
            }else{
                backmanage_layout.classList.add('side-shrink');
                hidden_menu_btn.classList.add('active');
            }
        });
    }
}());
